﻿<UserControl x:Class="ScrumFactory.Windows.AlertMessage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:props="clr-namespace:ScrumFactory.Windows.Properties"
             xmlns:SFWindows="clr-namespace:ScrumFactory.Windows"
             xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"             
             ClipToBounds="True"
             Visibility="Collapsed"
             mc:Ignorable="d"           
             x:Name="thisView"
             d:DesignHeight="80" d:DesignWidth="300">
    <UserControl.InputBindings>
        <KeyBinding Key="Esc" Command="{Binding CloseWindowCommand}"/>
    </UserControl.InputBindings>
    
            
    
    <Border 
        x:Name="border" Style="{StaticResource AlertBorder}" CornerRadius="0" BorderThickness="0,0,0,2"
        HorizontalAlignment="Stretch" >
        
        <Grid x:Name="grid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>            
            <Image Grid.Column="0" 
               VerticalAlignment="Top"
               Source="{Binding ImageSource}" Margin="0,0,10,0"
               Width="32" Height="32" Stretch="Uniform">
                <Image.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ImageSource}" Value="{x:Null}">
                                <Setter Property="Image.Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Image.Style>
            </Image>
            <StackPanel Grid.Column="1">
                <TextBlock FontWeight="Bold" Text="{Binding Title}" TextWrapping="Wrap" Margin="0,0,0,7"/>
                <TextBlock Text="{Binding Message}" TextWrapping="Wrap" Foreground="{StaticResource AlertBrush}"/>
            </StackPanel>          
            <Button
                Grid.Column="2"
                x:Name="closeButton"
                Style="{StaticResource AlertButton}"
                VerticalAlignment="Top" 
                Command="{Binding CloseWindowCommand}"
                Content="{x:Static props:Resources.Close}"/>
                

        </Grid>
        
                
        
    </Border>
    <UserControl.Triggers>
        <EventTrigger  RoutedEvent="SFWindows:AlertMessage.TurnedVisible">
            <BeginStoryboard>
                <Storyboard Storyboard.TargetName="border">
                    <ThicknessAnimation Duration="00:00:0.3"
                        To="0,0,0,0"
                        From="{Binding ElementName=border, Path=ActualHeight, Converter={StaticResource MarginConverter}}"  Storyboard.TargetProperty="Margin"/>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </UserControl.Triggers>
    
    
</UserControl>
